home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / gtlayout / source / ltp_makemenu.c < prev    next >
C/C++ Source or Header  |  1999-04-19  |  1KB  |  61 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #include "Assert.h"
  15.  
  16. #ifdef DO_MENUS    /* Support code */
  17.  
  18.     /* LTP_MakeMenu(RootMenu *Root,MenuNode *Menu,struct NewMenu *Template):
  19.      *
  20.      *    Create a single menu and fill it in.
  21.      */
  22.  
  23. MenuNode *
  24. LTP_MakeMenu(RootMenu *Root,MenuNode *Menu,struct NewMenu *Template)
  25. {
  26.         // If none is provided, roll our own
  27.  
  28.     if(!Menu)
  29.         Menu = (MenuNode *)AsmAllocPooled(Root->Pool,sizeof(MenuNode),SysBase);
  30.  
  31.     if(Menu)
  32.     {
  33.         STRPTR Label = Template->nm_Label;
  34.  
  35.             // Use the screen font for the layout
  36.  
  37.         SetFont(&Root->RPort,Root->DrawInfo->dri_Font);
  38.  
  39.             // Fill in the size
  40.  
  41.         Menu->Menu.Width    = TextLength(&Root->RPort,Label,strlen(Label)) + 8;
  42.         Menu->Menu.Height    = Root->Screen->BarHeight;
  43.  
  44.         Menu->Menu.MenuName    = (BYTE *)Label;
  45.         Menu->UserData        = Template->nm_UserData;
  46.  
  47.             // Return to the original font
  48.  
  49.         SetFont(&Root->RPort,Root->Font);
  50.  
  51.             // Take care of the only valid bit
  52.  
  53.         if(!(Template->nm_Flags & NM_MENUDISABLED))
  54.             Menu->Menu.Flags = MENUENABLED;
  55.     }
  56.  
  57.     return(Menu);
  58. }
  59.  
  60. #endif    /* DO_MENUS */
  61.